<template>
  <el-tabs type="border-card">
    <el-tab-pane>
      <span slot="label">
        <i class="el-icon-date">密码登陆</i>
      </span>
      <el-form ref="form" :model="form" label-width="80px">
        <el-row>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-select v-model="value" clearable placeholder="选择归属地">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </el-col>
          <el-col :span="16">
            <div class="grid-content bg-purple-light">
              <el-input
                type="text"
                placeholder="手机号"
                v-model="text1"
                maxlength="11"
                show-word-limit
              ></el-input>
            </div>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="18">
            <div class="grid-content bg-purple-dark">
              <el-input placeholder="验证码" v-model="input1">
                <div>
                  <el-tooltip class="item" effect="dark" content="Top Center 提示文字" placement="top"></el-tooltip>
                </div>
              </el-input>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple-light">
              <img class="attribution" :src="Attribution" />
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="16">
            <div class="grid-content bg-purple">
              <el-input
                type="text"
                placeholder="请输入6位短信验证码"
                v-model="text2"
                maxlength="6"
                show-word-limit
              ></el-input>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple-light">
              <el-button type="text" @click="centerDialogVisible = true">获取短信验证码</el-button>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="16">
            <div class="grid-content bg-purple-light" id="blank"></div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple-light">
              <el-button type="text" @click="centerDialogVisible = true">接受语音验证码</el-button>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="tip">
              <p>未注册手机验证后自动登录，注册即代表同意</p>
              <a href="http://www.zhihu.com/term/zhihu-terms">《知乎协议》</a>
              <a href="http://www.zhihu.com/term/privacy">《隐私保护协议》</a>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="registered">
              <el-button class="registered-button" type="primary" round>注册/登陆</el-button>
            </div>
          </el-col>
        </el-row>
        <el-dialog title="提示" :visible.sync="centerDialogVisible" width="30%">
          <span>验证码已发送</span>
          <span slot="footer" class="dialog-footer">
            <el-button @click="centerDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
          </span>
        </el-dialog>
        <el-row :gutter="20">
          <el-col :span="8">
            <p>社交账号登录</p>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="wechat"></svg-icon>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="qq"></svg-icon>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="weibo"></svg-icon>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <div class="expand">
            <el-col :span="8">
              <p>
                <svg-icon icon-class="certification"></svg-icon>开通机构号
              </p>
            </el-col>
            <el-col :span="16">
              <P>
                <svg-icon icon-class="zhihu"></svg-icon>下载知乎app
              </P>
            </el-col>
          </div>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane label="免密码登陆">
      <el-form ref="form" :model="form" label-width="80px">
        <el-row id="switch1">
          <el-col :span="24">
            <div class="grid-content bg-purple-light">
              <el-input type="text" placeholder="手机号或邮箱" v-model="text1" show-word-limit></el-input>
            </div>
          </el-col>
        </el-row>
        <el-row id="switch2">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-select v-model="value" clearable placeholder="选择归属地">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </el-col>
          <el-col :span="16">
            <div class="grid-content bg-purple-light">
              <el-input
                type="text"
                placeholder="手机号"
                v-model="text1"
                maxlength="11"
                show-word-limit
              ></el-input>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-content bg-purple-dark">
              <el-input placeholder="密码" v-model="input" show-password></el-input>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="18">
            <div class="grid-content bg-purple-dark">
              <el-input placeholder="验证码" v-model="input1">
                <div>
                  <el-tooltip class="item" effect="dark" content="Top Center 提示文字" placement="top"></el-tooltip>
                </div>
              </el-input>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple-light">
              <img class="attribution" :src="Attribution" />
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-button type="text" @click="Switch()">海外手机号登陆</el-button>
          </el-col>
          <el-col :span="12">
            <el-button type="text" @click="forget()">忘记密码</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24"></el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="tip">
              <p>未注册手机验证后自动登录，注册即代表同意</p>
              <a href="http://www.zhihu.com/term/zhihu-terms">《知乎协议》</a>
              <a href="http://www.zhihu.com/term/privacy">《隐私保护协议》</a>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="registered">
              <el-button class="registered-button" type="primary" round>注册/登陆</el-button>
            </div>
          </el-col>
        </el-row>
        <el-dialog title="提示" :visible.sync="centerDialogVisible" width="30%">
          <span>验证码已发送</span>
          <span slot="footer" class="dialog-footer">
            <el-button @click="centerDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
          </span>
        </el-dialog>
        <el-row :gutter="20">
          <el-col :span="8">
            <p>社交账号登录</p>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="wechat"></svg-icon>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="qq"></svg-icon>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="weibo"></svg-icon>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <div class="expand">
            <el-col :span="8">
              <p>
                <svg-icon icon-class="certification"></svg-icon>开通机构号
              </p>
            </el-col>
            <el-col :span="16">
              <P>
                <svg-icon icon-class="zhihu"></svg-icon>下载知乎app
              </P>
            </el-col>
          </div>
        </el-row>
      </el-form>
    </el-tab-pane>
    <el-tab-pane>
      <span slot="label">
        <img class="code" :src="Code" />
      </span>
      <div class="code-container">
        <div class="code-title">扫码登陆</div>
        <div class="code-contain">
          <img class="qrcode" :src="Qrcode" />
        </div>
      </div>
      <el-form ref="form" :model="form" label-width="80px">
        <el-row :gutter="20">
          <el-col :span="8">
            <p>社交账号登录</p>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="wechat"></svg-icon>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="qq"></svg-icon>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="icon">
              <svg-icon icon-class="weibo"></svg-icon>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <div class="expand">
            <el-col :span="8">
              <p>
                <svg-icon icon-class="certification"></svg-icon>开通机构号
              </p>
            </el-col>
            <el-col :span="16">
              <P>
                <svg-icon icon-class="zhihu"></svg-icon>下载知乎app
              </P>
            </el-col>
          </div>
        </el-row>
      </el-form>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import Attribution from "./attribution.gif";
import Code from "@/assets/codes.png";
import Qrcode from "@/assets/code.png";
export default {
  data() {
    return {
      Code,
      Qrcode,
      Attribution,
      text1: "",
      text2: "",
      input1: "",
      input: "",
      centerDialogVisible: false,
      dialogVisible: false,
      form: {
        name: "MainForm",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      options: [
        {
          value: "选项1",
          label: "中国 +86",
        },
        {
          value: "选项2",
          label: "美国 +1",
        },
        {
          value: "选项3",
          label: "日本 +81",
        },
        {
          value: "选项4",
          label: "中国香港 +852",
        },
        {
          value: "选项5",
          label: "中国澳门 +853",
        },
      ],
      value: "",
    };
  },
  methods: {
    Switch() {
      if (switch1.style.display === "block") {
        switch1.style.display = "none";
        switch2.style.display = "block";
      } else {
        switch2.style.display = "none";
        switch1.style.display = "block";
      }
    },
    forget() {
      window.open("https://www.zhihu.com/account/password_reset");
    },
    onSubmit() {
      console.log("submit!");
    },
    querySearch(queryString, cb) {
      var attribution = this.attribution;
      var results = queryString
        ? attribution.filter(this.createFilter(queryString))
        : attribution;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return (restaurant) => {
        return (
          restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
          0
        );
      };
    },
    loadAll() {
      return [
        {
          value: "中国 +86",
        },
        {
          value: "美国 +1",
        },
        {
          value: "日本 +81",
        },
        {
          value: "中国香港 +852",
        },
        {
          value: "中国澳门 +853",
        },
        {
          value: "中国台湾 +886",
        },
        {
          value: "马来西亚 +60",
        },
        {
          value: "加拿大 +1",
        },
        {
          value: "英国 +44",
        },
      ];
    },
    handleSelect(item) {
      console.log(item);
    },
    handleIconClick(ev) {
      console.log(ev);
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
  },
  mounted() {
    this.attribution = this.loadAll();
  },
};
</script>
<style lang="scss" scoped>
.my-autocomplete {
  li {
    line-height: normal;
    padding: 7px;

    .name {
      text-overflow: ellipsis;
      overflow: hidden;
    }
    .addr {
      font-size: 12px;
      color: #b4b4b4;
    }

    .highlighted .addr {
      color: #ddd;
    }
  }
}
.el-row {
  margin-bottom: 0px;
  &:last-child {
    margin-bottom: -15px;
    margin-left: -15px;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.code {
  width: 52px;
  height: 52px;
  position: absolute;
  left: 130px;
}
.qrcode {
  margin: 0 auto 24px;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  position: relative;
  height: 150px;
  width: 150px;
}
.code-container {
  position: relative;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}
.code-title {
  font-weight: 500;
  font-size: 24px;
  color: #1a1a1a;
  line-height: 33px;
  margin-bottom: 41px;
  margin-top: 3px;
}
#switch2 {
  display: none;
}
.expand {
  box-sizing: border-box;
  margin: 0;
  min-width: 0;
  padding-left: 24px;
  padding-right: 24px;
  color: #0084ff;
  width: 400px;
  height: 60px;
  -webkit-align-items: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  background-color: #f6f6f6;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}
.icon {
  position: relative;
  top: 14px;
}
#blank {
  opacity: 0;
}
.registered {
  text-align: center;
}
.registered-button {
  width: 200px;
}
.attribution {
  height: 32px;
}
.tip {
  font-size: 13px;
}
</style>
